package projetolp2.GraphicInterface;


import java.awt.Component;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import projetolp2.Sistem.Sistema;

public class RankingGeral extends MealPoints implements ActionListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JPanel panelRankingGeral = new JPanel(new GridLayout(0, 1));
	private JPanel panel1 = new JPanel(new GridLayout(0, 1));
	private JPanel panel2 = new JPanel(new GridLayout(0, 1));
	private JButton VOLTAR = new JButton(NomeBotoes.values()[idioma(IDIOMAPROGRAMA )].getVoltar());
	private final JLabel label = new JLabel("Ranking dos estabelecimentos: ");
	public RankingGeral(){
		
	}
	public void setQuantidade(int valor){
	}
	//Metodo para colocar os textos de ajuda dos botoes
	private void ajudaDeBotoes(){
		VOLTAR.setToolTipText("Voltar a janela anterior");
	}
	//Metodo responsavel por verificar qual a acao foi feita e fazer as devidas mudancas na janela
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == VOLTAR){
			removerAdicionar(rank,menu);
			
		}
	}
	//metodo responsavel por implementas os botoes, painel e etc
	private void createComponents() {
		ajudaDeBotoes();
        
        VOLTAR.setMnemonic(KeyEvent.VK_I);
        VOLTAR.addActionListener(this);
        label.setLabelFor(VOLTAR);
         
        String valorees = "ERROR";
        try {
			valorees = "PONTOS   -   ESTABELECIMENTO;"+SISTEMA.rankingGeralString();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JList texto = new JList(valorees.split(";"));
		
        System.out.println(texto.getSelectedIndex());
       // panel1.add(label);
        panel1.add(new JScrollPane(texto));
        panel1.setBorder(BorderFactory.createEmptyBorder(
                0, //top
                10, //left
                0, //bottom
                10) //right
                );
        
        panel2.add(VOLTAR);
        panel2.setBackground(cor);
        panel1.setBackground(cor);
        panel2.setBorder(BorderFactory.createEmptyBorder(
                80, //top
                150, //left
                80, //bottom
                150) //right
                );
        
        panelRankingGeral.add(panel1);
        panelRankingGeral.add(panel2);
        panelRankingGeral.setBorder(BorderFactory.createEmptyBorder(
                10, //top
                30, //left
                10, //bottom
                30) //right
                );
    }
	//cria e retorna o painnel
	public Component panel(){
		createComponents();
		panelRankingGeral.setVisible(true);
		
		
		return panelRankingGeral;
	}	
}